using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;
namespace Test {
	class DonRfStat {
		static void MainX() {
			string sql=@"select convert(char(16),ChangeTime,20)date,fromApplication,rtrim(address)adr,count(*)cnt
from rfStateChangeBonusLog(nolock)where datediff(day,ChangeTime,getdate())=1
group by convert(char(16),ChangeTime,20),fromApplication,address order by 1";
			DAL don=new DAL("pon-wpsq21-db06\\in06","rf");
			DataTable tab=don.Query(sql);
			DAL local=new DAL();
			//local.NonQry("create table DonMStat(id int identity,date datetime,app varchar(30),ip varchar(15),cnt int)");
			foreach(DataRow row in tab.Rows)
			{
				local.NonQry("insert into DonMStat(date,app,ip,cnt)values(convert(datetime,'{0:yyyy-MM-dd HH:mm}',20),'{1}','{2}',{3})",row["date"],row["fromApplication"],row["adr"],row["cnt"]);
			}
		}
	}
}
